/*
 * @Author: 码上talk|RC
 * @Date: 2020-06-09 23:23:29
 * @LastEditTime: 2020-10-09 16:41:39
 * @LastEditors: 码上talk|RC
 * @Description: 
 * @FilePath: /tacomall-merchant/src/store/index.js
 * @Just do what I think it is right
 */
/*eslint-disable */
import Vue from 'vue'
import Vuex from 'vuex'

import user from './user'

import { session } from '@/libs/session'
import { historyBar } from '@/utils/history-bar'

Vue.use(Vuex)

export const store = new Vuex.Store({
    modules: {
        user
    },
    state: {
        isLogin: false,
        menu: [
            {
                title: '商城首页',
                path: '/index',
                icon: 'icon-shouye'
            },
            {
                title: '商品管理',
                path: '/goods',
                icon: 'icon-shangpin',
                sub: [
                    {
                        title: '商品列表',
                        path: '/goods/list'
                    }
                ]
            },
            {
                title: '订单管理',
                path: '/order',
                icon: 'icon-ordercenter',
                sub: [
                    {
                        title: '订单列表',
                        path: '/order/list'
                    }
                ]
            },
            {
                title: '营销推广',
                path: '/promote',
                icon: 'icon-yingxiao',
                sub: [
                    {
                        title: '优惠券',
                        path: '/promote/coupon'
                    },
                    {
                        title: '限时抢购',
                        path: '/promote/seckill'
                    }
                ]
            },
            {
                title: '账户中心',
                path: '/account',
                icon: 'icon-geren',
                sub: [
                    {
                        title: '用户资料',
                        path: '/account/profile'
                    },
                    {
                        title: '账户设置',
                        path: '/account/setting'
                    }
                ]
            }
        ],
        historyBar: []
    },
    mutations: {
        setIsLogin(state, b) {
            state.isLogin = b
        },
        refreshHistoryBar(state) {
            state.historyBar = historyBar.all()
        }
    },
    actions: {
        appInit({ dispatch }) {
            session.get() && dispatch('user/getUserInfo')
        }
    }
})
